import ConfigParser
import os

def writeVar(fileName, sectionName, sectionKey, sectionValue):
    config = ConfigParser.ConfigParser()
    if os.path.exists(fileName):
        config.read(fileName)
    try:
        config.set(sectionName, sectionKey, sectionValue)
    except:
        config.add_section(sectionName)
        config.set(sectionName, sectionKey, sectionValue)
    with open(fileName, "wb") as configFile:
        config.write(configFile)
        configFile.close()

def getVar(fileName, sectionName, sectionKey):
    config = ConfigParser.ConfigParser()
    if os.path.exists(fileName) == True:
        try:
            config.read(fileName)
            return config.get(sectionName, sectionKey)
        except:
            return ""
    else:
        return ""


